﻿using BoriPeter.FitnessJournal8.Models;
using BoriPeter.NutritionFileSource.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BoriPeter.NutritionFileSource.Converters
{
    public static class FoodConverter
    {
        public static Food Convert(this FoodItem _foodItem)
        {
            Food food = new Food();
            food.Name = _foodItem.Name;
            food.Brand = _foodItem.Brand;
            food.Id = _foodItem.Id;
            if (_foodItem.Images.Count > 0)
                food.ImageName = _foodItem.Images[0];

            return food;
        }

        public static List<Food> Convert(this List<FoodItem> _foodList)
        {
            List<Food> list = new List<Food>();
            foreach (var foodXML in _foodList)
                list.Add(foodXML.Convert());

            return list;
        }
    }
}
